<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>初始vue</title>
    <script type="text/javascript"  src="../js/vue.js"></script>
  
</head>

<!-- v-for指令:
1.用于展示列表数据
2.语法: v-for="(item， index) in xxx” :key="yyy"
3.可遍历: 数组、对象、字符串 (用的很少) 、指定次数 (用的很少) -->
<body>
    <div id="root">
        <h2>人员列表</h2>
       <button @click="updateMei">点击更新马冬梅信息</button>
       <ul>
        <li v-for="(p,index) in persons" :key="p.id">
            {{p.name}} - {{p.age}} - {{p.sex}}
        </li>
       </ul>
       <ul>
       
     </div>
</body>

<script type="text/javascript">
   Vue.config.productionTip=false;


let vm =new Vue({
        el:"#root",
        data:{
            persons: [ 
            {id:'001',name:'马冬梅',age:119,sex:'女'},
            {id:'002',name:'周冬雨',age:202,sex:'女'},
            {id:'003',name:'周杰伦',age:2133,sex:'男'},
            {id:'004',name:'温兆伦',age:221,sex:'男'}
            ] 
        },
        methods: {
            updateMei(){
                // this.persons[0]={id:'001',name:'马老师',age:50,sex:'男'}  不奏效
                this.persons.splice(0,1,{id:'001',name:'马老师',age:50,sex:'男'})

            }
        },
    })
    
</script>
</html>